<?php

// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议  https://mit-license.org 
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------

namespace app\api\controller;


use app\common\controller\IndexController;


use app\api\library\login\wxLogin;
use app\api\library\login\wechatLogin;
use app\api\library\login\updateUser;
use app\api\library\login\getPhone;
use app\api\library\login\sendMsg;

/**
 * Class Login
 * @package app\index\controller
 */
class Login extends IndexController
{
    /**
     * 登录
     */
    public function wxLogin()
    {
        $req = $this->run(WEB_KEY);
//        $req = request()->param();
        //处理参数
        $display = [
            ['code', 'ce', 'str'],
        ];
        $param   = _displayParam($req, $display);
        wxLogin\V::run($param);
    }
    
    public function wechatLogin()
    {
        $req = $this->run(WEB_KEY);
//        $req = request()->param();
        //处理参数
        $display = [
            ['mobile', 'me', 'int'],
            ['code', 'ce', 'str'],
            ['openId', 'oi', 'str'],
            ['promotionId', 'pi', 'int'],
        ];
        //校验参数
        $param = _displayParam($req, $display);
        
        
        wechatLogin\V::run($param);
    }
    /**
     * 创建或更新用户信息
     */
    public function updateUser()
    {
        $req = $this->run(WEB_KEY);
//        $req = request()->param();
        //处理参数
        $display = [
            ['openId', 'oi', 'str'],
            ['nickName', 'ne', 'str'],
            ['mobile', 'me', 'int'],
            ['avatarUrl', 'au', 'str'],
            ['gender', 'gr', 'int'],
            ['province', 'pv', 'str'],
            ['city', 'ct', 'str'],
            ['country', 'cy', 'str'],
        ];
        //校验参数
        $param = _displayParam($req, $display);
        
        
        updateUser\V::run($param);
    }
    
    public function getPhone()
    {
        $req = $this->run(WEB_KEY);
//        $req = request()->param();
        //处理参数
        $display = [
            ['userId', 'ui', 'int'],
            ['code', 'ce', 'str'],
        ];
        //校验参数
        $param = _displayParam($req, $display);
        
        
        getPhone\V::run($param);
    }
    
    public function sendMsg()
    {
        $req = $this->run(WEB_KEY);
//        $req = request()->param();
        //处理参数
        $display = [
            ['mobile', 'me', 'int'],
        ];
        //校验参数
        $param = _displayParam($req, $display);
        
        
        sendMsg\V::run($param);
    }
}
